<?php

function p($params) {
    echo "<pre>";
    print_r($params);
    die;
}

/**
 * 成功后返回
 * @param string $message
 * @param array $data
 * @param array $headers
 * @param int $options
 * @return \Illuminate\Http\JsonResponse
 */
function responseJsonSuccess($message = '',array $data = [], array $headers = [], $options = 0)
{
    return response()->json([
        'code' => 200,
        'message' => $message,
        'data' => $data ?: new stdClass()
    ], $status = 200, $headers, $options);
}

/**
 * 失败后返回
 * @param int $code
 * @param string $message
 * @param array $data
 * @param array $headers
 * @param int $options
 * @return \Illuminate\Http\JsonResponse
 */
function responseJsonError($code = 400, $message = '',array $data = [], array $headers = [], $options = 0)
{
    return response()->json([
        'code' => $code,
        'message' => $message,
        'data' => $data ?: new stdClass()
    ], $status = 200, $headers, $options);
}
